<template>
	<view>
		<tab-nav :orderStaArr="orderStaArr" :orderStaIndex="orderStaIndex" @switchStatus="switchStatus" colType="redBg"></tab-nav>
		<view class="yhqList">
			<template v-if="hasYhqFlag">
				<yhq-list :useStatus="useStatus" :yhqList="yhqList" :hasYhqFlag="hasYhqFlag" yhqType="myYhq" :loading="loading" @goUseYhq="goUseYhq"></yhq-list>
			</template>
			<template v-else-if="hasYhqFlag == false">
				<no-data></no-data>
			 </template>
		</view>
	</view>
</template>

<script>
	import TabNav from '@/components/tab-nav/tab-nav'
	import YhqList from '../../index/components/YhqList.vue'
	import yhqMixin from '@/utils/yhqMixin.js'
	export default {
		components:{
			TabNav,
			YhqList
		},
		mixins:[yhqMixin],
		data(){
			return{
				orderStaArr:[
					{id:1,name:'未使用'},
					{id:2,name:'已使用'},
					{id:3,name:'已过期'}
				],
				orderStaIndex:0,
				useStatus:1
			}
		},
		onLoad(){
			this.getMyYhq();
		},
		onPullDownRefresh : function(){
			this.initParams();
			uni.stopPullDownRefresh();
		},
		onReachBottom : function(){
			if( !this.loading   && this.hasNextFlag){
				this.getMyYhq();
			}
		},
		methods:{
			switchStatus(index,id){
				this.orderStaIndex = index;
				this.useStatus = id;
				this.initParams();
			},
			initParams(){
				this.nowPageYhq = 1;
				this.loading = false;
				this.yhqList = [];
				this.getMyYhq();
			},
			goUseYhq(yhqType){
				if(this.useStatus == 1){
					if(yhqType == 'zx'){
						uni.switchTab({
							url:'/pages/xlzx/xlzx'
						})
					}else if(yhqType == 'cp'){
						uni.navigateTo({
							url:'/pages/subIndex/xlcp/xlcp'
						})
					}
				}
			}
		}
	}
</script>

<style lang="scss">
	page{
		background: #F6F6F6;
	}
	.yhqList{
		padding: 0 20rpx;
	}
</style>